Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • D-au 26 posts 76 karma points
    Nov 26, 2012 @ 06:35
    D-au
    0

    {umbraco.library:NiceUrl(@id)} can't work under 2 for each on the new schema

    Any one could tell me why this is not working? I'm using the new schema 4.5 and for this and it is wierd how the code only works when I strip out the second {umbraco.library:NiceUrl(@id)}:


    <ul style="list-style:none; display:inline;float:left;margin:5px 0 0 96px" class="drospdown">
    <xsl:for-each select="$absoluteRoot/*/*">
    <xsl:if test="./@id != 1078">
    <xsl:if test="./@id != 1079">

      
        <xsl:variable name="NaviNode" select="@nodeName" />
    <li style="float:left;font-size:14px; color:#FFFFFF">  
      
      
      
      <href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="./@nodeName"/></a>

        
              <ul>
                <xsl:for-each select="./*">
                  
                    <li>       
                   
                      <href="{umbraco.library:NiceUrl(@id)}"
    >
                 <xsl:value-of select="./@id" disable-output-escaping="yes"/>
                 <xsl:value-of select="./@nodeName" disable-output-escaping="yes"/>
                   </a>
                  </li>
                  
                
                  </xsl:for-each>
               </ul>
       
    </li>
     
      
      
      </xsl:if>
      </xsl:if>
      

    </xsl:for-each>
      </ul>

     

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Nov 26, 2012 @ 08:03
    Chriztian Steinmeier
    0

    Hi D-au,

    This happens because in the new schema you need to distinguish between documents and properties when a selector would select both types, e.g., when you say:

    <xsl:for-each select="$currentPage/*">

    You will get all of $currentPage's properties as well as its child pages. To select only pages (documents) add a 'predicate':

    <xsl:for-each select="$currentPage/*[@isDoc]">

    and you will only get document nodes. (So the error you get happens when NiceUrl() tries to take the @id attribute of one of the page's properties.)

    Here's a cleaned up version of what you were doing:

    <ul class="drospdown">
        <xsl:for-each select="$absoluteRoot/*/*[@isDoc][not(@id = 1078 or @id = 1079]">
            <li>  
                <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
                <ul>
                    <xsl:for-each select="*[@isDoc]">
                        <li>       
                            <a href="{umbraco.library:NiceUrl(@id)}">
                                <xsl:value-of select="@id" />
                                <xsl:value-of select="@nodeName" />
                            </a>
                        </li>
                    </xsl:for-each>
                </ul>
            </li>
        </xsl:for-each>
    </ul>

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft